package com.san.message;



import com.hzk.utils.JsonUtil;

import com.hzk.pojo.UserBasic;
import com.san.serviceImpl.DroolServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;


@Service
@Slf4j
public class MQReceiver {

    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    DroolServiceImpl droolService;

    @RabbitListener(queues = "droolQueue")
    public void receive(String msg ) {
        log.info("QUEUE接受消息：" + msg);
        applicationMessage message = JsonUtil.jsonStr2Object(msg,
                applicationMessage.class);
        Long goodsId = message.getId();
        UserBasic userBasic = message.getUserBasic();
        String request = message.getRequest();
        String token = message.getToken();
        droolService.executeRule(userBasic,goodsId,token);
        log.info("成功！！");
    }
}
